package cn.tedu.boot31.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/*此注解作用: 相当于添加了@Controller注解和
* 每一个里面的方法都添加了ResponseBody注解*/
@RestController
public class AxiosController {
    @RequestMapping("/helloAxios")
    @ResponseBody
    public String helloAxios(){
        return "服务器接受到了请求!";
    }
    @RequestMapping("/test01")
    public String test01(String info){
        return "接受到了"+info;
    }

    @RequestMapping("bmi")
    public String bmi(float h,float w){

        float bmi = w/ (h*h);
        String info = null;
        if (bmi<18.5){
            info="兄弟你瘦了";
        }else if (bmi<24){
            info = "体重正常";
        }else if (bmi<30){
            info = "微胖";
        }else {
            info = "肥胖";
        }
        return info;
    }
    @RequestMapping("/check")
    public String check(String username){
        if (username.equals("tom")){
            return "用户名已存在!";
        }else {
            return "用户名可用!";
        }
    }
}
